package ModelLayer;

import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 */
public class AddressBook {
    private static AddressBook instance = new AddressBook();
    private ArrayList<Person> ab;

    /**
     * Constructor for objects of class AddressBook
     */
    private AddressBook() {
        if (ab == null) ab = new ArrayList<Person>();
    }

    public static AddressBook getInstance() {
        return instance;
    }

    public ArrayList<Person> get() {
        return ab;
    }

    public void set(ArrayList<Person> newAb) {
        ab = newAb;
    }

    public void add(Person person) {
        ab.add(person);
    }
}
/*public Person getPerson(long id){
Iterator <Person> person = ab.iterator();
while(person.hasNext()){
Person p = person.next();
if(p.getId() == id)return p;
}
return null;
}*/

/*public void set(long id, String name, String address, String postalCode, String city, String phone, String email){
for(int indx = 0 ; indx < ab.size() ; indx++){
if(ab.get(indx).getId() == id){
Person person = ab.get(indx);
person.setName(name);
person.setAddress(address);
person.setPostalCode(postalCode);
person.setCity(city);
person.setPhone(phone);
person.setEmail(email);
ab.set(indx, person);
return;
}
}
}*/

/*public void Remove(long id){
Iterator <Person> person = ab.iterator();
while(person.hasNext()){
Person p = person.next();
if(p.getId() == id){
person.remove();
return;
}
}
}*/
